﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Text;

namespace ImvuCacheViewer
{
    public class ProductInfo {
        public string ID { get; set; }
        public string Name { get; set; }
        public string Creator { get; set; }
        public string ImageUrl { get; set; }
        public DateTime Date { get; set; }
        public Image Image {
            get {
                string imgName = Path.Combine(Form1.ProgCachePath, ID + ".img");
                if (File.Exists(imgName)) {
                    return Image.FromFile(imgName);
                }
                return null;
            }
        }

        public ProductInfo() {}
        public ProductInfo(string line) {
            string[] pieces = line.Split('\t');
            ID = pieces[0];
            Name = pieces[1];
            Creator = pieces[2];
            ImageUrl = pieces[3];
            Date = DateTime.Parse(pieces[4]);
        }

        public override string ToString() {
            string result = string.Empty;
            result += ID + "\t";
            result += Name + "\t";
            result += Creator + "\t";
            result += ImageUrl + "\t";
            result += Date + "\t";
            return result;
        }

    }
}
